<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>添加分类</title>

  <!-- bootstrap -->
  <link rel="stylesheet" href="./assets/css/bootstrap.min.css" />

  <!-- animate.css -->
  <link rel="stylesheet" href="./assets/css/animate.min.css" />

  <!-- MUI -->
  <link rel="stylesheet" href="./assets/plugins/mui/css/mui.min.css">

  <!-- 重置样式 -->
  <link rel="stylesheet" href="./assets/css/reset.css" />

  <!-- 公共样式 -->
  <link rel="stylesheet" href="./assets/css/common.css" />

  <!-- 页面独立的 -->
  <link rel="stylesheet" href="./assets/css/ContactAdd.css" />
</head>
<style></style>
<body>
  <!-- 信息录入 -->
  <div class="info">
    <h3 class="title wow fadeInUp">添加分类名称</h3>

    <p class="desc wow fadeInUp" data-wow-delay="200ms" style="color: #fff;">
      您可在本页录入您的分类信息，录入成功后名片将会出现在首页。
    </p>
  </div>

  <form class="contact wow fadeInUp" data-wow-delay="300ms" method="post">
    <div class="form-group">
      <label for="name">分类名称</label>
      <input type="text" class="form-control" id="name" placeholder="请输入分类名称" required />
    </div>
    <div class="action">
      <button class="btn" type="submit">提交</button>
    </div>
  </form>
</body>

</html>
<!-- jquery  -->
<script src="./assets/js/jquery.min.js"></script>

<!-- bootstrap -->
<script src="./assets/js/bootstrap.min.js"></script>

<!-- wow.js -->
<script src="./assets/js/wow.min.js"></script>

<!-- MUI -->
<script src="./assets/plugins/mui/js/mui.min.js"></script>

<!-- axios请求 -->
<script src="./assets/plugins/axios/axios.js"></script>
<script src="./assets/plugins/axios/request.js"></script>

<!-- cookie -->
<script src="./assets/plugins/cookie.js"></script>

<!-- 校验用户是否登陆 -->
<script src="./assets/plugins/helper.js"></script>

<script>
  //实例化wow.js
  new WOW().init();
  let Business = cookie.get('Business') ? JSON.parse(cookie.get('Business')) : "{}";

  $("form").submit(async function (e) {
    e.preventDefault();
    // 上传修改
    let result = await POST({
      url: 'card/type/add', params: {
        businessid: Business.id,
        name: $("#name").val()
      }
    })
    // 成功提示和跳转页面
    if (result.code == 1) {
      mui.toast(result.msg);
      setTimeout(() => {
        location.href = 'typeIndex.html'
      }, 1000)
    } else {
      mui.toast(result.msg);
    }
  })

</script>